package sprites;

import java.awt.image.BufferedImage;
import java.lang.reflect.Constructor;
import java.util.List;
import java.util.ArrayList;
import java.util.Random;

import com.golden.gamedev.GameObject;
import com.golden.gamedev.object.Timer;

/**
 * A projectile that Bob fires, such as a bubble or a torpedo.
 */
public class Projectile extends BubblefishBobSprite
{

    private static String[] children =
    {
        "sprites.RedBubbleFired", "sprites.BlueBubbleFired",
        "sprites.GreenBubbleFired", "sprites.PurpleBubbleFired"
    };

    Timer bubbleTimer;

    public Projectile(GameObject owner, BufferedImage[] image,
            double x, double y)
    {
        super(owner, image, x, y);

        

        bubbleTimer = new Timer(100);
    }

    @Override
    public void update(long elapsedTime)
    {
        super.update(elapsedTime);
    }

    /**
     * Leaves a trail of air bubbles behind the projectile.
     */
    protected void makeBubbles(long elapsedTime)
    {
        // TODO: implement
    }

    @Override
    public void bob()
    {
        /*
         * Projectiles are not supposed to bob.
         */
        return;
    }

    public static Projectile getRandomProjectile(GameObject owner,
            double x, double y)
    {
        Random rng = new Random();
        Projectile p = null;
        try
        {
            String r = children[rng.nextInt(children.length)];
            Class<Projectile> cl = (Class<Projectile>)Class.forName(r);
            Constructor<Projectile> c =
                cl.getConstructor(owner.getClass().getSuperclass(),
                        double.class, double.class);
            p = c.newInstance(owner, x, y);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        return p;
    }

}
